package com.muk.meis.controller.school;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.muk.meis.model.bean.SchoolInfo;
import com.muk.meis.model.service.SchoolInfoService;

/**
 * Servlet implementation class SchoolEditController
 */
@WebServlet("/SchoolEditController")
public class SchoolEditController extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SchoolEditController() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
	    response.setContentType("text/html; charset=UTF-8");
	    String perCode = request.getParameter("percode");
		//String districtId = request.getParameter("district_id");
		String philosophy =request.getParameter("philosophy");
		String vision = request.getParameter("vision");
		String mission = request.getParameter("mission");
		String background = request.getParameter("background");
		
		SchoolInfo schoolInfo = new SchoolInfo();
		//schoolInfo.setDistrictId(Integer.parseInt(districtId));
		schoolInfo.setPercodeCode(perCode);
		schoolInfo.setPhilosophy(philosophy);
		schoolInfo.setVision(vision);
		schoolInfo.setMission(mission);
		schoolInfo.setBackground(background);
		
		SchoolInfoService service = new SchoolInfoService();
		service.update(schoolInfo);
		
		response.sendRedirect("school/listnews.jsp?percode="+perCode+"#tabs-6");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
